package day09.handler.simpleChannelHandler;

import day09.packet.MessageResponsePacket;
import day09.util.LoginUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.Date;

/**
 * @author chenshijie
 * @date 2023/12/26 13:39
 */

public class MessageResponseHandler extends SimpleChannelInboundHandler<MessageResponsePacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MessageResponsePacket messageResponsePacket) throws Exception {
        if (LoginUtil.hasLogin(ctx.channel())) {
//            log.println(new Date() + ": 收到了服务端的消息: " + messageResponsePacket.getMessage());
            System.out.println(new Date() + ": 收到了服务端的消息: " + messageResponsePacket.getMessage());
        }
    }
}
